<template>
        <div class>
             <el-card class="ep-card ep-search">
               <el-row :gutter="0">
                 <el-col :span="2" style="float:right">
                   <el-button type="success"  @click="save">保存</el-button>
                 </el-col>
               </el-row>
             </el-card>
       
             <el-card header="	企业经营情况分析	">
             <el-form :model="analyBusOperForm" ref="analyBusOperForm" label-width="140px" class="demo-analyBusOperForm" size="mini">
                 <el-form-item label="企业经营情况分析" prop="analyBusOper">
                   <el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="analyBusOperForm.analyBusOper" style="width: 100%;"></el-input>
                 </el-form-item>
             </el-form>
             </el-card>
       
       
       
        </div>
</template>
<script>
export default {
    data(){
        return {
          analyBusOperForm: {
            analyBusOper: "",
          },
          projId:'',
          isSaveOrUpdate:false,
        }
      },
      mounted() {
      },
      methods: {
      init(projId){
        this.projId=projId;
        this.$api.formPost( 'biz/projAnalyBusOper/doGetList',{
                    projId:projId
                  }).then(res => {
                    if(res.retHead.code=="0000000"){
                        let isSaveOrUpdate=false;
                        if(res.retBody.list.length>0){
                          this.analyBusOperForm=res.retBody.list[0];
                           isSaveOrUpdate=true;
                        }
                        this.isSaveOrUpdate=isSaveOrUpdate;
                    }else{
                        this.$message({
                            type: 'error',
                            message: res.retHead.message
                        });
                    }
                });
      },
        save(){
          let analyBusOper=this.analyBusOperForm;
          let user=JSON.parse(sessionStorage.getItem("user"));
          analyBusOper.createUserId=user.id;
          analyBusOper.createUserName=user.realName;
          analyBusOper.borrowEnt=this.entName;
          analyBusOper.projId = this.projId;
          if(!this.isSaveOrUpdate){
            this.$api.post( '/api/biz/projAnalyBusOper/doSaveAnalyBusOper',analyBusOper).then(res => {
                  if(res.retHead.code="0000000"){
                        this.$message({
                            type: 'success',
                            message: "保存成功"
                        });
                        //关闭弹框并清空数据
                        this.analyBusOperForm = {};
                        this.$emit("hiddenComponent");
                    }else{
                        this.$message({
                            type: 'error',
                            message: res.retHead.message
                        });
                    }
            });
        }else{
          this.analyBusOperForm.createTime=new Date();
          this.$api.formPost( '/api/biz/projAnalyBusOper/doModById',this.analyBusOperForm).then(res => {
                  if(res.retHead.code="0000000"){
                        this.$message({
                            type: 'success',
                            message: "更新成功"
                        });
                        //关闭弹框并清空数据
                        this.analyBusOperForm = {};
                        this.$emit("hiddenComponent");
                    }else{
                        this.$message({
                            type: 'error',
                            message: res.retHead.message
                        });
                    }
            });
        }
       }
          
    }
}
</script>